package modelewithstatemachine;

import java.util.Comparator;

public class TaxiComparator implements Comparator<TaxiWithStateMachine> {
	private ClientAroundStateMachineOMGIMSURROUNDED client;
	
	public TaxiComparator(ClientAroundStateMachineOMGIMSURROUNDED client) {
		this.client = client;
	}
	
	@Override
	public int compare(TaxiWithStateMachine t1, TaxiWithStateMachine t2) {
		double distTo1 = Math.sqrt((client.getY() - t1.getY())*(client.getY() - t1.getY()) + (client.getX() - t1.getX())*(client.getX() - t1.getX()));
		double distTo2 = Math.sqrt((client.getY() - t2.getY())*(client.getY() - t2.getY()) + (client.getX() - t2.getX())*(client.getX() - t2.getX()));
		
		if(distTo1 < distTo2)
			return -1;
		else if(distTo1 > distTo2)
			return 1;
		else
			return 0;
	}

}
